package ThreadCase;

import java.util.concurrent.FutureTask;

public class Demo3Lambda {
    public static void main(String[] args) {
        FutureTask<String> ft1=new FutureTask<>(()->{
            //求1~100之间的和
            int sum=0;
            for (int i = 1; i <=100 ; i++) {
                sum+=i;//子增加i
            }
            //返回当前线程的名称+最终求和结果
            return Thread.currentThread().getName()+":"+sum;
        });

        new Thread(ft1).start();
        System.out.println(ft1);
    }
}
